<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/admin_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <title>登录</title>
    <!--semantic-ui的cdn引入-->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
</head>
<body>
    <div class="ui container" style="max-width: 30em !important; margin: 150px;">
        <div class="column">
            <h2 class="ui teal image header">
                <div class="content">
                    后台管理-登录
                </div>
            </h2>
            <!--登录表单-->
            <form class="ui large form" method="post" th:action="@{/admin/login}">
                <div class="ui segment">
                    <div class="field">
                        <div class="ui left icon input">
                            <i class="user icon"></i>
                            <input type="text" name="username" placeholder="用户名">
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left icon input">
                            <i class="lock icon"></i>
                            <input type="password" name="password" placeholder="密码">
                        </div>
                    </div>
                    <button class="ui fluid large teal submit button">Login</button>
                </div>
                <!--用户名，密码为空时的消息提示区域-->
                <div class="ui error message"></div>
                <!--登录失败时的消息提示区域-->
                <div class="ui mini negative message" th:unless="${#strings.isEmpty(message)}" th:text="${message}">用户名和密码错误</div>
            </form>
        </div>
    </div>


    <!--引入jquery和semantic-ui-->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
    <script>
        //表单验证
        $('.ui.form').form({
            fields:{
                //用户名部分
                username:{
                    //和name保存一致
                    identifier:'username',
                    //规则
                    rules:[{
                        type:'empty',
                        prompt:'请输入用户名'
                    }]
                },
                //密码部分
                password:{
                    //和name保存一致
                    identifier:'password',
                    //规则
                    rules:[{
                        type:'empty',
                        prompt:'请输入密码'
                    }]
                }
            }
        })
    </script>
</body>
</html>